Download this Jupyter notebook


Instrument view

A simple version of the Mantid instrument view is available in scipp. It currently does not support detector ‘picking’ and manual drawing of masks, but basic functionalities such as different 2D and 3D projections, as well as navigation through the time-of-flight dimension via a slider, are provided.

Note

The files used in this notebook were taken from the Mantid training course data.

Warning

While you can interact with the 3D view of the instrument, the buttons and sliders will have no effect in the documentation pages, as there is no kernel to perform the operations. These will only work inside a Jupyter notebook.

The instrument view is part of the scipp.neutron module, and it is launched as follows:

[1]:
import numpy as np
import scipp.neutron as sn
[2]:
sample = sn.load(filename='PG3_4871_event.nxs', advanced_geometry=True)
[3]:
sn.instrument_view(sample)
[3]:

By default, the 3D view is rendered. Switching to a cylindrical or spherical view is achieved easily by using the buttons below the figure.

The projection can also be selected on creation using the projection keyword argument:

[4]:
sn.instrument_view(sample, projection="Cylindrical Y")
[4]:

It is also possible to use the usual arguments for customizing the figure, e.g.

[5]:
sn.instrument_view(sample, cmap="magma", vmax=1.5, bins=10, log=True)
[5]:

This works for any file that can be loaded by Mantid that contains a valid instrument description or geometry.

There are also two different rendering modes:

  • Full rendering (default): the shape, size and orientation of detector pixels is fully reproduced. Interactions can be slower due to a heavier computational load.

  • Fast rendering: for maximum performance, only the positions of the detectors are correctly represented. The pixels are displayed as 2D squares.

Rendering can be changed in a dropdown menu or using a keyword argument:

[6]:
sn.instrument_view(sn.load(filename='GEM40979.raw'), rendering='Fast')
[6]: